package com.zmht.beike.biz.impl;

import java.io.Serializable;
import java.util.List;

import com.zmht.beike.biz.IWeekContentBiz;
import com.zmht.beike.core.BaseBizImpl;
import com.zmht.beike.po.TIweekcontent;

public class IWeekContentBizImpl extends BaseBizImpl implements IWeekContentBiz {

	public boolean deleteIWeekContent(Serializable id) {
		try{
			Object obj = this.getIweekContentDAO().findById(TIweekcontent.class, id);
			if(obj!=null){
				this.getIweekContentDAO().deleteObj(obj);
			}
		}catch(Exception e){
			return false;
		}
		return true;
	}

	public TIweekcontent findById(Serializable id) {
		
		return (TIweekcontent)this.getIweekContentDAO().findById(TIweekcontent.class, id);
	}

	public boolean saveIWeekContent(TIweekcontent weekcontent) {
		try{
			this.getIweekContentDAO().saveObj(weekcontent);
		}catch(Exception e){
			return false;
		}
		return true;
	}

	public boolean updateIWeekContent(TIweekcontent weekcontent) {
		try{
			this.getIweekContentDAO().updateObj(weekcontent);
		}catch(Exception e){
			return false;
		}
		return true;
	}

	public List getIweekcontent(String teacherId,Integer iaimId,Integer month,Integer week, int startIndex, int pageSize) {
		String hql = "from TIweekcontent t where t.teacherId = "+teacherId+" and t.imonthId=null and t.iaimId="+iaimId+" and t.month="+month+" and t.weekId="+week;
		return this.getIweekContentDAO().findByPage(hql, startIndex, pageSize);
	}

	public int getIweekcountTotal(String teacherId,Integer iaimId,Integer month,Integer week) {
		String hql = "from TIweekcontent t where t.teacherId = "+teacherId+" and t.imonthId=null and t.iaimId="+iaimId+" and t.month="+month+" and t.weekId="+week;
		return this.getIweekContentDAO().findByHQLObj(hql).size();
	}

	public List getIweekcontentEdit(Integer targetId, Integer teacherId,
			Integer month, String week, int startIndex, int pageSize) {
		String hql = "from TIweekcontent t where t.teacherId="+teacherId+" and t.iaimId="+targetId+" and t.month="+month+" and t.weekId="+week;
		return this.getIweekContentDAO().findByPage(hql, startIndex, pageSize);
	}

	public int getIweekcontentEditTotal(Integer targetId, Integer teacherId,
			Integer month, String week) {
		String hql = "from TIweekcontent t where t.teacherId="+teacherId+" and t.iaimId="+targetId+" and t.month="+month+" and t.weekId="+week;
		return this.getIweekContentDAO().findByPageAmount(hql);
	}

}
